#include "stdafx.h"
#include "truetype_os2.h"
#include "truetype.h"

void truetype_os2(truetype_t * tt, tt_table_t * table)
{
	if(!tt || !tt->stream || !table || table->type != tt_table_type_OS2)
		return ;
	base_stream_t * stream = tt->stream;

	tt_os2_t os2 = {0};

	stream->seeker(stream, table->offset, stream_seek_begin);
	stream->reader(stream, &os2, 
		sizeof(tt_os2_t) - sizeof(tt_metrics_extra_t) - sizeof(tt_metrics_extra2_t));

	os2.version = confirm_big_word(os2.version);

	if(os2.version > tt_version_truetype_1_5)
	{
		stream->reader(stream, &(os2.extra), sizeof(tt_metrics_extra_t));
	}
	else
	{
		os2.code_page_range_1 = 0;
		os2.code_page_range_2 = 0;
	}

	if(os2.version > tt_version_truetype_1_6_6)
	{
		stream->reader(stream, &(os2.extra2), sizeof(tt_metrics_extra2_t));
	}
	else
	{
		os2.height = 0;
		os2.cap_height = 0;
		os2.default_char = 0;
		os2.break_char = 0;
		os2.max_context = 0;
	}
}


